export const CHANGE_LANGUAGE = 'change_language';
export const ADD_LANGUAGE = 'add_language';

//定义俩个接口
interface ChangeLanguageAction{
    type: typeof CHANGE_LANGUAGE,
    payload: "zh" | "en"
}
interface AddLanguageAction{
    type: typeof ADD_LANGUAGE,
    payload:  {name: string, code: string}
}
//导出 ChangeLanguageAction 或者 AddLanguageAction 给 languageReducer.ts用定义变量的类型
export type languageActionTypes = ChangeLanguageAction | AddLanguageAction

//: ChangeLanguageAction ：return的类型为ChangeLanguageAction
 export const changeLanguageActionCreator = (languageCode: "zh" | "en"): ChangeLanguageAction =>{
    return {
        type: CHANGE_LANGUAGE,
        payload:languageCode,
    };
}
//: AddLanguageAction ：return的类型为AddLanguageAction
export const addLanguageActionCreator = (name: string, code: string): 
AddLanguageAction  =>{
    return {
        type: ADD_LANGUAGE,
        payload: { name, code },
}
}